/*
** KSS
** 4 bytes "KSCC" (old format) or "KSSX" (new format)
** 2 bytes load offset
** 2 bytes load size
** 2 bytes init address
** 2 bytes play address
** 4 bytes flags
*/

// KSS Flags
#define KSCC_YM2413          1
#define KSCC_SMS_MODE        2
#define KSCC_RAM             4
#define KSCC_GAMEGEAR_STEREO 4 // Same as above except used in SMS mode
#define KSCC_MSXAUDIO        8


#define KSS_TYPE_KSCC "KSCC"
#define KSS_TYPE_KSSX "KSSX"

typedef struct{
	
	// This is all loaded in from a KSS file
	UINT32 header;
	UINT16 load_offset;
	UINT16 load_size;
	UINT16 init_addr;
	UINT16 play_addr;

	// first_bank represents the first page number (anything before this page will not
	// be initialized or used). 
	UINT8  first_bank;

	UINT8  bank_count; // if top bit set, we're using 8 kb banks
	UINT8  reserved;   // This is always 0 for KSCC, for KSSX this points to a title string
	UINT8  flags;

	UINT8  stuff[0x10]; // IMPLEMENTANS LATAR


	// Stuff that isn't present in KSS files
	UINT16 banksize;

}  KSSHeader;


class CKSSFile {
	private:
		FILE_HANDLE fHandle;
		KSSHeader header;
		CMemory* maincode;
		CMemory* bankcode;

	public:
		~CKSSFile();

	public:
		int Open(const char* filename);

		KSSHeader* GetHeader();

		CMemory* GetBankedData(); // Banked datas
		CMemory* GetMainCode(); // Main data stuff

};